<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2 id="myapplication5App.studentScore.home.createOrEditLabel" data-cy="StudentScoreCreateUpdateHeading">
          Create or edit a StudentScore
        </h2>
        <div>
          <div class="form-group" v-if="studentScore.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="studentScore.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="student-score-score">Score</label>
            <input
              type="number"
              class="form-control"
              name="score"
              id="student-score-score"
              data-cy="score"
              :class="{ valid: !$v.studentScore.score.$invalid, invalid: $v.studentScore.score.$invalid }"
              v-model.number="$v.studentScore.score.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="student-score-scoreStatus">Score Status</label>
            <input
              type="number"
              class="form-control"
              name="scoreStatus"
              id="student-score-scoreStatus"
              data-cy="scoreStatus"
              :class="{ valid: !$v.studentScore.scoreStatus.$invalid, invalid: $v.studentScore.scoreStatus.$invalid }"
              v-model.number="$v.studentScore.scoreStatus.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="student-score-student">Student</label>
            <select class="form-control" id="student-score-student" data-cy="student" name="student" v-model="studentScore.student">
              <option v-bind:value="null"></option>
              <option
                v-bind:value="studentScore.student && studentOption.id === studentScore.student.id ? studentScore.student : studentOption"
                v-for="studentOption in students"
                :key="studentOption.id"
              >
                {{ studentOption.id }}
              </option>
            </select>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="student-score-teacher">Teacher</label>
            <select class="form-control" id="student-score-teacher" data-cy="teacher" name="teacher" v-model="studentScore.teacher">
              <option v-bind:value="null"></option>
              <option
                v-bind:value="studentScore.teacher && teacherOption.id === studentScore.teacher.id ? studentScore.teacher : teacherOption"
                v-for="teacherOption in teachers"
                :key="teacherOption.id"
              >
                {{ teacherOption.id }}
              </option>
            </select>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="student-score-userClass">User Class</label>
            <select class="form-control" id="student-score-userClass" data-cy="userClass" name="userClass" v-model="studentScore.userClass">
              <option v-bind:value="null"></option>
              <option
                v-bind:value="
                  studentScore.userClass && userClassOption.id === studentScore.userClass.id ? studentScore.userClass : userClassOption
                "
                v-for="userClassOption in userClasses"
                :key="userClassOption.id"
              >
                {{ userClassOption.id }}
              </option>
            </select>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.studentScore.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./student-score-update.component.ts"></script>
